{% extends 'myadmin/index.html' %}
{% block con %}
<div class="content">
    <div class="container-fluid">
        <div class="row">
            <div class="col-md-12">
                <div class="card">
                    <form action="{% url 'user_edit_post' %}?uid={{ data.id }}" method="POST" enctype="multipart/form-data"
                          class="am-form tpl-form-line-form">
                        {% csrf_token %}
                        <div class="card-header">
                            <div class="card-title">会员编辑</div>
                        </div>

                        <div class="card-body">
                            <div class="form-group">
                                <label>昵称</label>
                                <input type="text" class="form-control"  name="nikename" value="{{data.nikename}}" placeholder="请输入昵称">
                                <small id="emailHelp" class="form-text text-muted">请输入个性的昵称
                                </small>
                            </div>
                            <div class="form-group">
                                <label for="password">密码</label>
                                <input type="password" class="form-control" id="password" name="password"
                                       placeholder="请输入密码">
                            </div>

                            <div class="form-group">
                                <label for="password">手机号</label>
                                <input type="text" class="form-control" id="phone" value="{{data.phone}}" name="phone"
                                       placeholder="请输入手机号">
                            </div>

                            <div class="form-group">
                                <label for="email">邮箱</label>
                                <input type="email" class="form-control" id="email" name="email" value="{{data.email}}"  placeholder="请输入邮箱">
                            </div>

                            <div class="form-group">
                                <label for="email">年龄</label>
                                <input type="text" class="form-control" id="age" value="{{data.age}}" name="age" placeholder="请输入年龄">
                            </div>

                            <div class="form-check">
                                <label>性别</label><br/>
                                <label class="form-radio-label">
                                    <input class="form-radio-input" type="radio"  name="sex" value="0"
                                           checked="">
                                    <span class="form-radio-sign">女</span>
                                </label>
                                <label class="form-radio-label ml-3">
                                    <input class="form-radio-input" type="radio" name="sex" value="1">
                                    <span class="form-radio-sign">男</span>
                                </label>
                            </div>


                            <div class="form-group">
                                <label for="exampleFormControlFile1">头像</label>
                                <input type="file" class="form-control-file" name="pic"
                                       id="exampleFormControlFile1" value="{{data.pic_url}}">
                                <img src="{{data.pic_url}}" alt="">
                            </div>


                        </div>
                        <div class="card-action">
                            <button class="btn btn-success">提交</button>
                            <input class="btn btn-danger" type="reset" value="重置"/>
                        </div>
                </div>
                </form>
            </div>

        </div>
    </div>
</div>
</div>

{% endblock %}
<script type="text/javascript">
    $('.select-status').change(function(){
        // 获取当前元素的 值
        var status = $(this).val()
        // 获取当前元素的 id
        var uid = $(this).attr('uid')

        // 发送ajax请求.修改状态
        $.get('{% url 'myadmin_user_set_status' %}',{'uid':uid,'status':status},function(data){
            // 判断当前的返回值
            if(data['code'] == 0){
                alert(data['msg'])
            }
        },'json')


    })
</script>